using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.SqlClient;


namespace Acms.SqlDal
{
    public class UserPostVoteAverageDal : Base
    {
        public enum Fields
        {
            PostGuid,
            //SiteId,
            //PostName,
            //PostDisplayName,
            //ParentId,
            //ParentPath,
            Average,
            Total
        }

        protected override void ReadRecord(Hashtable table, SqlDataReader reader)
        {
            GetReaderValue<Guid>(Fields.PostGuid, reader, table);
            //GetReaderValue<int>(Fields.SiteId, reader, table);
            //GetReaderValue<string>(Fields.PostName, reader, table);
            //GetReaderValue<string>(Fields.PostDisplayName, reader, table);
            //GetReaderValue<int>(Fields.ParentId, reader, table);
            //GetReaderValue<string>(Fields.ParentPath, reader, table);
            GetReaderValue<decimal>(Fields.Average, reader, table);
            GetReaderValue<int>(Fields.Total, reader, table);
        }

        public Hashtable GetByPostGuid(Guid postGuid)
        {
            SqlCommand cmd = CreateCommand("GetByPostGuid");
            AddInputParameter(cmd, "PostGuid", postGuid, SqlDbType.UniqueIdentifier);
            return ExecuteGetItem(cmd);
        }

        public Hashtable[] GetAllBySiteId(int siteId)
        {
            SqlCommand cmd = CreateCommand("GetAllBySiteId");
            AddInputParameter(cmd, "SiteId", siteId, SqlDbType.Int);
            return ExecuteGetCollection(cmd);
        }
    }
}
